//
//  YDLoginViewModel.m
//  YDRACLearn
//
//  Created by rowena on 2019/1/9.
//  Copyright © 2019年 wuyezhiguhun. All rights reserved.
//

#import "YDLoginViewModel.h"

@implementation YDLoginViewModel

- (instancetype)init {
    self = [super init];
    if (self) {
        [self setLoginViewModelRAC];
    }
    return self;
}

/**
 * 设置RAC
 */
- (void)setLoginViewModelRAC {
    self.loginButtonSignal = [RACSignal combineLatest:@[RACObserve(self, userName), RACObserve(self, password)] reduce:^id _Nonnull(NSString *userName, NSString *password) {
        
        NSLog(@"self :<**>: userName->: %@  password->: %@", self.userName, self.password);
        NSLog(@"userName->: %@  password->: %@", userName, password);
        
        return @(userName.length && (password.length > 5));
    }];
    
    self.loginCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal * _Nonnull(id  _Nullable input) {
        
        return [RACSignal createSignal:^RACDisposable * _Nullable(id<RACSubscriber>  _Nonnull subscriber) {
            
            
            return [RACDisposable disposableWithBlock:^{
                
            }];
        }];
        
    }];
}

@end
